home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / GIMP 2.6.8 / gimp-2.6.8-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / distress-selection.scm < prev    next >
Text File  |  2009-12-15  |  4KB  |  117 lines

  1. ;
  2. ; distress selection
  3. ;
  4. ;
  5. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  6. ; At ECS Dept, University of Southampton, England.
  7.  
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. ; Define the function:
  23.  
  24. (define (script-fu-distress-selection inImage
  25.                                       inDrawable
  26.                                       inThreshold
  27.                                       inSpread
  28.                                       inGranu
  29.                                       inSmooth
  30.                                       inSmoothH
  31.                                       inSmoothV)
  32.  
  33.   (let (
  34.        (theImage inImage)
  35.        (theWidth (car (gimp-image-width inImage)))
  36.        (theHeight (car (gimp-image-height inImage)))
  37.        (theLayer 0)
  38.        (theMode (car (gimp-image-base-type inImage)))
  39.        )
  40.  
  41.   (gimp-image-undo-group-start theImage)
  42.   (if (= theMode GRAY)
  43.     (set! theMode GRAYA-IMAGE)
  44.     (set! theMode RGBA-IMAGE)
  45.     )
  46.   (set! theLayer (car (gimp-layer-new theImage
  47.                                       theWidth
  48.                                       theHeight
  49.                                       theMode
  50.                                       "Distress Scratch Layer"
  51.                                       100
  52.                                       NORMAL-MODE)))
  53.  
  54.   (gimp-image-add-layer theImage theLayer 0)
  55.  
  56.   (if (= FALSE (car (gimp-selection-is-empty theImage)))
  57.       (gimp-edit-fill theLayer BACKGROUND-FILL)
  58.   )
  59.  
  60.   (gimp-selection-invert theImage)
  61.  
  62.   (if (= FALSE (car (gimp-selection-is-empty theImage)))
  63.       (gimp-edit-clear theLayer)
  64.   )
  65.  
  66.   (gimp-selection-invert theImage)
  67.   (gimp-selection-none inImage)
  68.  
  69.   (gimp-layer-scale theLayer
  70.                     (/ theWidth inGranu)
  71.                     (/ theHeight inGranu)
  72.                     TRUE)
  73.  
  74.   (plug-in-spread RUN-NONINTERACTIVE
  75.                   theImage
  76.                   theLayer
  77.                   inSpread
  78.                   inSpread)
  79.  
  80.   (plug-in-gauss-iir RUN-NONINTERACTIVE
  81.              theImage theLayer inSmooth inSmoothH inSmoothV)
  82.   (gimp-layer-scale theLayer theWidth theHeight TRUE)
  83.   (plug-in-threshold-alpha RUN-NONINTERACTIVE theImage theLayer inThreshold)
  84.   (plug-in-gauss-iir RUN-NONINTERACTIVE theImage theLayer 1 TRUE TRUE)
  85.   (gimp-selection-layer-alpha theLayer)
  86.   (gimp-image-remove-layer theImage theLayer)
  87.   (if (and (= (car (gimp-drawable-is-channel inDrawable)) TRUE)
  88.            (= (car (gimp-drawable-is-layer-mask inDrawable)) FALSE))
  89.     (gimp-image-set-active-channel theImage inDrawable)
  90.     )
  91.   (gimp-image-undo-group-end theImage)
  92.  
  93.   (gimp-displays-flush)
  94.   )
  95. )
  96.  
  97.  
  98. (script-fu-register "script-fu-distress-selection"
  99.   _"_Distort..."
  100.   _"Distress the selection"
  101.   "Chris Gutteridge"
  102.   "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  103.   "23rd April 1998"
  104.   "RGB*,GRAY*"
  105.   SF-IMAGE       "The image"              0
  106.   SF-DRAWABLE    "The layer"              0
  107.   SF-ADJUSTMENT _"Threshold (bigger 1<-->255 smaller)" '(127 1 255 1 10 0 0)
  108.   SF-ADJUSTMENT _"Spread"                 '(8 0 1000 1 10 0 1)
  109.   SF-ADJUSTMENT _"Granularity (1 is low)" '(4 1 25 1 10 0 1)
  110.   SF-ADJUSTMENT _"Smooth"                 '(2 1 150 1 10 0 1)
  111.   SF-TOGGLE     _"Smooth horizontally"    TRUE
  112.   SF-TOGGLE     _"Smooth vertically"      TRUE
  113. )
  114.  
  115. (script-fu-menu-register "script-fu-distress-selection"
  116.                          "<Image>/Select/Modify")
  117.